#!coding=utf-8
from __future__ import unicode_literals
from datetime import datetime

from django.db import models
from django.contrib.auth.models import AbstractUser


# Create your models here.


class UserProfile(AbstractUser):
    nick_name = models.CharField(verbose_name=u'昵称', max_length=50, default='')
    QQ = models.CharField(verbose_name=u'QQ号码', max_length=20, blank=True, null=True)
    wechat = models.CharField(verbose_name=u'微信', max_length=50, blank=True, null=True)
    image = models.ImageField(verbose_name=u'用户头像', max_length=50, upload_to='user/%Y/%m', default='user/default.png')
    mobile = models.CharField(verbose_name=u'电话号码', max_length=11 ,default='')
    gender = models.SmallIntegerField(verbose_name=u'性别', choices=((1, u"男"), (0, "女")), default=1)
    add_time = models.DateTimeField(verbose_name=u'加入时间', default=datetime.now)

    class Meta:
        verbose_name = u'用户信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username.encode('utf-8')


class EmailVerifyRecord(models.Model):
    code = models.CharField(max_length=20, verbose_name=u"验证码")
    email = models.EmailField(max_length=50, verbose_name=u"邮箱")
    send_type = models.SmallIntegerField(verbose_name=u"验证码类型", choices=((0,u"注册"),(1,u"找回密码"), (3,u"修改邮箱")))
    send_time = models.DateTimeField(verbose_name=u"发送时间", default=datetime.now)

    class Meta:
        verbose_name = u"邮箱验证码"
        verbose_name_plural = verbose_name

    def __str__(self):
        return '{0}({1})'.format(self.code, self.email)